﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AviationMath
{
    public static class E6bOperations
    {
        public static double CrosswindComponent(double heading, double windDir, double windSpeed)
        {
            double angle = DegreesToRadians(windDir) - DegreesToRadians(heading);
            return windSpeed * Math.Sin(angle);
        }

        public static double HeadwindComponent(double heading, double windDir, double windSpeed)
        {
            double angle = DegreesToRadians(windDir) - DegreesToRadians(heading);
            return windSpeed * Math.Cos(angle);
        }

        public static double DegreesToRadians(double degrees)
        {
            return degrees * (Math.PI / 180);
        }
    }
}
